package org.smoozik.app.common.piano;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class PianoListener implements MouseListener,
		MouseMotionListener {
	PianoPanel panel;

	public PianoListener(PianoPanel panel) {
		this.panel = panel;
	}
	
	@Override
	public void mousePressed(MouseEvent e) {
		PianoKey key = panel.getFigureForMouse(e);
		panel.updateKeyPressed(key);
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		panel.setCurrentNote(null);
		panel.setCurrentFigure(null);
		if(panel.getPianoClient() != null) {
			panel.getPianoClient().keyReleased();
		}
	}

	@Override
	public void mouseDragged(MouseEvent e) {
		PianoKey key = panel.getFigureForMouse(e);
		panel.updateKeyPressed(key);
	}

	@Override
	public void mouseEntered(MouseEvent e) {
	}

	@Override
	public void mouseExited(MouseEvent e) {
	}

	@Override
	public void mouseMoved(MouseEvent e) {
	}

	@Override
	public void mouseClicked(MouseEvent e) {
	}

}
